<?php
/**
 * ZView
 *
 * Zend Frameworks View Component for TYPO3
 *
 * @package    ZView
 * @copyright  Copyright (c) Zephir AG, www.zephir.ch
 */

/** Abstract class for extension */
require_once 'Zend/View/Helper/Abstract.php';

/**
 * Helper to generate a cached "image" element
 *
 * @package ZView
 * @copyright  Copyright (c) Zephir AG, www.zephir.ch
 */
class Tx_Zview_Helper_T3page extends Zend_View_Helper_Abstract
{

	/**
	 * @var array
	 */
	private $_page;

	/**
	 *
	 *
	 * @param string $key
	 * @return string
	 */
    public function t3page($key)
    {
    	$page = $this->_getPage();
    	return array_key_exists($key, $page) ? $page[$key] : null;
	}

	/**
	 * @return array
	 */
	private function _getPage()
	{
		if(is_null($this->_page)) {
			$pid = $GLOBALS['TSFE']->cObj->data['uid'];
			$this->_page = $GLOBALS['TSFE']->sys_page->getPage($pid);
		}
		return $this->_page;
	}

}


if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/zview/helper/T3page.php']) {
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/zview/helper/T3page.php']);
}
